//设置中心点为北京
var city_center_index="fjtekqrposNKGE,hrlphplnJOOE";
//var city_center_index="lqgxpkowoHHLL,jiomsrpujuPDLH";
//设置地图初始化参数对象
var mapOptions = new MMapOptions();
mapOptions.mapId = "fmptest";
mapOptions.zoomLevel = 10;
mapOptions.center = new MLatLng(city_center_index);
//创建地图对象
var mapObj = new MMap("mapObj", mapOptions);
mapObj.showNavigator(true);

//注册地图初始化完成事件 地图初始化完执行 mapInited() 方法
mapObj.addEventListener(MMap.EVENT_MAP_INITIALIZED, mapInited);

//注册鼠标画点后事件
mapObj.addEventListener(MMap.EVENT_POINT_DRAWN, pointDrawn);

var polylineStyle = new MStyle();
polylineStyle.lineColor = 0xff0000;
polylineStyle.lineSize = 5;
var polyline = new MPolylineOverlay([new MLatLng("qqhrqjgojKHEJ", "oipgkglllgOLIJ"),
new MLatLng("qqhrqfhohODMF","oipgkgmgljOLIJ"), 
new MLatLng("qqhrplmojOLMJ","oipgkgmihkGHIN")],polylineStyle, "1001");
function mapInited(){
	//beginDrawPointOnMap();
}

function beginDrawPointOnMap(){
	mapObj.removePointById('1001');
	var pointStyle = new MStyle();
	pointStyle.lineColor = 0x445599;
	pointStyle.lineSize = 3;
	pointStyle.fillColor = 0xaa9900;
	pointStyle.fillOpacity = 30;
	pointStyle.label = "一个点";
	pointStyle.textContent = "鼠标画点";
	mapObj.beginDrawPointOnMap(pointStyle);
}

function pointDrawn(event){
	//删除上一个点
	var lastpoint = document.getElementById('lastpoint').value;
	//mapObj.removeAllPointOverlays()	
	mapObj.removeGeometryById(lastpoint,MGeometry.TYPE_POINT);

	var maparray = event.args.split(',');
	var pointLng = maparray[2];
	var pointLat = maparray[3];
	var pointnow = maparray[4];

	document.getElementById('lastpoint').value = pointnow;
	document.getElementById('xy').value = '"'+pointLat+'","'+pointLng+'"';
	mapObj.quitMouseDraw();
}